package com.xiaoyu.lanling.feature.fate.model

import `in`.srain.cube.request.JsonData
import `in`.srain.cube.views.list.ListPositionedItemBase
import com.xiaoyu.base.model.User
import com.xiaoyu.lanling.feature.user.model.UserExtra
import com.xiaoyu.lanling.feature.vip.model.VipInfo
import com.xiaoyu.lanling.media.image.ImageLoadParam
import com.xiaoyu.lanling.media.image.UserImageLoadParam

class MainFateUserItem(position: Int, jsonData: JsonData) : ListPositionedItemBase(position) {

    private val userJson: JsonData = jsonData.optJson("user")

    val user: User = User.fromJson(userJson)
    val verify = userJson.optString("verify") == UserExtra.VerifyStatus.SUCCESS
    val tag: String = jsonData.optString("tag")
    val soliloquy: String = jsonData.optString("soliloquy")
    val vipInfo = VipInfo(jsonData.optJson("vipInfo"))
    var selected = false

    val avatarLoadParams: ImageLoadParam
        get() = UserImageLoadParam.newBuilder().setUserAndDP(user, 72).build()

    override fun getViewType(): Int {
        return 0
    }
}